<?php

class VideosController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }

    public function indexAction()
    {
        // action body
		$this->_helper->viewRenderer->setNoRender(true);
		$this->_helper->layout->disableLayout();
		return $this->_helper->redirector('lista','videos');
    }

    public function listaAction()
    {
        // action body
        $this->view->headScript()->appendFile('/js/jquery.pajinate.js');
		
        $videoObj = new Application_Model_Video();
        $videos = $videoObj->getLast20();
		
		$arrVideo = array();
        
		foreach($videos as $v){
			Zend_Loader::loadClass("Zend_Gdata_YouTube");
		   	try{
				$YouTube = new Zend_Gdata_Youtube();
				//Get the specific video
			  	$video = $YouTube->getVideoEntry($v["url"]);
			  
			  	array_push($arrVideo, $video);
		   	}catch(Zend_Service_Exception $e){ throw $e; }
		}
		
        $this->view->videos = $arrVideo;
		
		$obj_noticias = new Application_Model_Noticia();
		$noticias_footer = $obj_noticias->getLastLimit(2);
		$this->view->noticias_footer = $noticias_footer;
		
		$obj_videos = new Application_Model_Video();
		$video_footer = $obj_videos->getLastVideo();
		$this->view->video_footer = $video_footer[0];
		
		$obj_cartones = new Application_Model_Carton();
		$carton_footer = $obj_cartones->getLastCarton();
		$this->view->carton_footer = $carton_footer;
    }
}



